package com.dfrz.stockMarket.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dfrz.stockMarket.bean.MessageBean;
import com.dfrz.stockMarket.bean.StockBean;
import com.dfrz.stockMarket.bean.UserBean;
import com.dfrz.stockMarket.model.StocksModel;
import com.dfrz.stockMarket.service.StockService;

public class PageCtrl extends BaseController{
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String path = req.getContextPath();
		String name=req.getParameter("name");
		
	
			UserBean userBean = getSessionUserBean(req);
			System.out.println("user---"+userBean);
			List<StocksModel> stockBeans;
			try {
				stockBeans = StockService.getAllStock();
				setSession(req, "list", stockBeans);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		req.setAttribute("path", path);
		req.setAttribute("uname", name);
		req.getRequestDispatcher("/WEB-INF/page/index.jsp").forward(req, resp);
		

	}
}
